<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/8/8
 * Time: 17:57
 */

namespace AppBundle\Task;


class AlertModelConfig
{
    /**
     * 开多
     */
    const FUTURES_OPEN_LONG = 1;
    /**
     * 开多
     */
    const FUTURES_OPEN_SHORT = 2;
    /**
     * 平多
     */
    const FUTURES_CLOSE_LONG = 3;
    /**
     * 平空
     */
    const FUTURES_CLOSE_SHORT = 4;
    /**
     * 买
     */
    const SPOT_BUY = 11;
    /**
     * 卖
     */
    const SPOT_SELL = 12;

    const OPEN_LONG = '期货_买入开多_OpenLong';
    const OPEN_SHORT = '期货_卖出开空_OpenShort';
    const CLOSE_LONG = '期货_卖出平多_CloseLong';
    const CLOSE_SHORT = '期货_买入平空_CloseShort';
    const BUY = '现货_买_Buy';
    const SELL = '现货_卖_Sell';

    protected $trade_type = [];

    public static function tradeTypes()
    {
        $defaults = [
            self::FUTURES_OPEN_LONG => self::OPEN_LONG,
            self::FUTURES_OPEN_SHORT => self::OPEN_SHORT,
            self::FUTURES_CLOSE_LONG => self::CLOSE_LONG,
            self::FUTURES_CLOSE_SHORT => self::CLOSE_SHORT,
            self::SPOT_BUY => self::BUY,
            self::SPOT_SELL => self::SELL,
        ];
        return $defaults;
    }
    
    public static function tradeTypeName($type, $default = null)
    {
        switch ($type) {
            case self::FUTURES_OPEN_LONG:
                return self::OPEN_LONG;
            case self::FUTURES_OPEN_SHORT:
                return self::OPEN_SHORT;
            case self::FUTURES_CLOSE_LONG:
                return self::CLOSE_LONG;
            case self::FUTURES_CLOSE_SHORT:
                return self::CLOSE_SHORT;
            case self::SPOT_BUY:
                return self::BUY;
            case self::SPOT_SELL:
                return self::SELL;
        }
        return $default;
    }
}